# 损失函数
def compute_loss(outputs, boundary_box_label_1, damage_type, stn_transformed_boxes, boundary_box_label_2):
    # YOLO检测和分类损失
    detection_loss = outputs['loss']  # YOLO内置损失
    # 配准损失（IoU）
    iou_loss = compute_iou_loss(stn_transformed_boxes, boundary_box_label_2)
    total_loss = detection_loss + 0.5 * iou_loss  # λ = 0.5
    return total_loss

def compute_iou_loss(boxes1, boxes2):
    # 计算IoU损失（示例实现）
    return 1 - torch.mean(calculate_iou(boxes1, boxes2))

def calculate_iou(boxes1, boxes2):
    # IoU计算逻辑（省略具体实现）
    pass